package com.web.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.web.dao.TUserBalanceRecordDao;
import com.web.model.TUserBalanceRecord;
import com.web.service.TUserBalanceRecordService;
import com.web.model.PageBean;
import com.web.utils.Pager;

/**
 * 用户资金记录 Service实现
 * @author wzy
 * 
 */
@Service
public class TUserBalanceRecordServiceImpl implements TUserBalanceRecordService{

	//protected Log log = LogFactory.getLog(getClass());
	@Autowired
	private TUserBalanceRecordDao userBalanceRecordDao;//注入TUserBalanceRecord的dao
	
	
	public int insert(TUserBalanceRecord userBalanceRecord){
		return userBalanceRecordDao.insert(userBalanceRecord);
	}
	
	
	public int deleteByPrimaryKey(Long balanceId){
		return userBalanceRecordDao.deleteByPrimaryKey(balanceId);
	}
	
	
	public int updateByPrimaryKey(TUserBalanceRecord userBalanceRecord){
		return userBalanceRecordDao.updateByPrimaryKey(userBalanceRecord);
	}

	
	public TUserBalanceRecord selectByPrimaryKey(Long balanceId){
		return userBalanceRecordDao.selectByPrimaryKey(balanceId);
	}
	
	
	
	public List<TUserBalanceRecord> selectList(Map<String,Object> map){
		return userBalanceRecordDao.selectList(map);
	}
	
	
	public PageBean<TUserBalanceRecord> selectListByPage(Map<String,Object> map){
		Pager.addPage(map);
		Integer count = userBalanceRecordDao.selectListCount(map);
		List<TUserBalanceRecord> list = userBalanceRecordDao.selectList(map);
		PageBean<TUserBalanceRecord> pageList = new PageBean<TUserBalanceRecord>(list);
		pageList.setTotal(count);
		pageList.setList(list);
		pageList.setPageNum((Integer)map.get("pageNum"));
		pageList.setPageSize((Integer)map.get("pageSize"));
		pageList.setPages(Pager.getPages(count, (Integer)map.get("pageSize")));
		return pageList;
	}
	
	
	public TUserBalanceRecord selectByModelSelective(TUserBalanceRecord userBalanceRecord){
		return  userBalanceRecordDao.selectByModelSelective(userBalanceRecord);
	}
	
	
	public int selectListCount(Map<String, Object> map){
		return userBalanceRecordDao.selectListCount(map);
	}

	
	public void insertList(List<TUserBalanceRecord> list) {
		userBalanceRecordDao.insertList(list);
	}

	
	public PageBean<TUserBalanceRecord> selectUserBalacneList(Map<String, Object> map) {
		Pager.addPage(map);
		Integer count = userBalanceRecordDao.selectListCount(map);
		List<TUserBalanceRecord> list = userBalanceRecordDao.selectUserBalacneList(map);
		PageBean<TUserBalanceRecord> pageList = new PageBean<TUserBalanceRecord>(list);
		pageList.setTotal(count);
		pageList.setList(list);
		pageList.setPageNum((Integer)map.get("pageNum"));
		pageList.setPageSize((Integer)map.get("pageSize"));
		pageList.setPages(Pager.getPages(count, (Integer)map.get("pageSize")));
		return pageList;
	}

	
	public Double selectTodayWin(Map<String, Object> map) {
		return userBalanceRecordDao.selectTodayWin(map);
	}
}
